<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <!-- 编码 -->
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!-- 兼容模式方案：IE以最高级模式渲染文档；使用Chrome Frame渲染。 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- H5页面窗口自动调整到设备宽度，并禁止用户缩放页面 -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" name="viewport">
    <!-- 当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari (ios7.0版本以后，safari上已看不到效果) -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <!-- 将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式 (可选default、black、black-translucent) -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!-- 忽略将页面中的数字识别为电话号码 -->
    <meta name="format-detection" content="telephone=no">
    <!-- 忽略Android平台中对邮箱地址的识别 -->
    <meta name="format-detection" content="email=no">
    <!-- 作者 -->
    <meta name="author" content="Cleam Lee">
    <!-- 关键词 -->
    <meta name="keywords" content="关键词">
    <!-- 描述信息 -->
    <meta name="description" content="描述信息">
    <!-- dns预解析 -->
    <link rel="dns-prefetch" href="//mini.eastday.com/" />
    <!-- favicon -->
    <link rel="shortcut icon" href="//mini.eastday.com/toutiaoh5/img/favicon.ico" />
    <link rel="bookmark" href="//mini.eastday.com/toutiaoh5/img/favicon.ico" type="image/x-icon"/>
    <link rel="apple-touch-icon-precomposed" href="//mini.eastday.com/toutiaoh5/img/favicon.ico">
    <!-- 标题 -->
    <title>雨硕发钱啦</title>
    <!-- 动态更新html字体大小（使用rem为单位时） -->
    <!-- 样式文件 -->
    <meta name="hotcss" content="design-width=750">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/redPocket.css">
    <script src="js/responsive.js"></script>
    <script src="js/jquery-3.2.1.min.js"></script>
    <script src="//resources.dftoutiao.com/songheng/public/ttapp.js"></script>
    <!--正式-->
    <script src="//resources.dftoutiao.com/songheng/public/actrandomhost.js"></script>
    <!-- <script src="//h5act2.dftoutiao.com/appact/songhongbao/time.php"></script> -->
    <!--test-->
<!--     <script src="//resources.dftoutiao.com/songheng/test_public/actrandomhost.js"></script>
    <script src="//test-h5act2.dftoutiao.com/appact/songhongbao/time.php"></script> -->
    <script src="js/entry.js" type="text/javascript"></script>
    <script src="js/layui.js" charset="utf-8"></script>
</head>
<body>
  <div class="container" id='page6' style='background:#ffffff;'>
      <div id='ttlogo'></div>
  		<ul id='ul'>
  			<li class='li1'>东方头条的红包</li>
  			<li class='li2'>恭喜发财，大吉大利</li>
  			<li class='li3' id='li3'><strong id='money1'>0</strong>元</li>
  			<li class='li4' id='li4'><span id='money2'>0</span>元现金红包已放入您的钱包!</li>
  		</ul>
      <div id='flow1'>
      </div>
  		<div class="footer">
        <div class="button" id='button'>炫耀一下</div>
  		</div>
      <section id="wuyaBg">
        <img src="img/wuya.png" alt="" class='wuya'>
      </section>
  </div>
<script type="text/javascript" src="//res.cdn.openinstall.io/openinstall.js"></script>
<script>
  function webViewDidLoad(){
    // console.log('每次执行');
    location.reload();
  }

  function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
  }

  $(function(){
      var name = '';
      var head = '';
      //获取参数
     var money = getQueryString('j') || 0;
     if(money == 'undefined' || !money || money <= 0){
        $('#ul').css('padding-bottom', '.68rem');
        $('#flow1').css('height', '8rem');
        $('#li3').hide();
        $('#li4').hide();
        $('#button').hide();
        // $('#button2').css({'marginLeft':'-3.09rem','width':'6.18rem'});
     }else{
        $('#money1,#money2').text(money);
     }

      $.ttapp.userinfo(function(ret){
              userinfo = ret;
              if(ret.Accid<=0)
              {
                  entry();
                  $('#login_pxh').click(function(){
                      $.ttapp.login();
                  })
                  return false;
              }else{
                head = ret.Image;
                name = ret.Nick;
              }



              $.ttapp.clientinfo(function(ret){
                  clientinfo = ret;
                    //上报统计
                    function report(type) {
                        const PARAM_EMPTY = 'null';
                        var road = 'app';
                        if (GetQueryString('push')) {
                            road = '14';
                        }
                        var statisData = {
                            'uid': clientinfo.IMEI ? clientinfo.IMEI : PARAM_EMPTY,
                            'from': 'app',
                            'softname': (clientinfo.OEM && clientinfo.Plantform)
                                ? (clientinfo.OEM + (clientinfo.Plantform == "android" ? "Android" : "IOS"))
                                : PARAM_EMPTY,
                            'appqid': clientinfo.QidWithTime ? clientinfo.QidWithTime : (clientinfo.Qid ? clientinfo.Qid : PARAM_EMPTY),
                            'ttaccid': userinfo.Accid ? userinfo.Accid : PARAM_EMPTY,
                            'thisurl': location.href,
                            'actentryid': road,
                            'actid': 'robredpack',
                            'materialid': 'https://kp.dftoutiao.com/shb_in/img/title.png',
                            'type': type,
                            'loginid': userinfo.Accid ? userinfo.Accid : PARAM_EMPTY,
                            'softtype': 'toutiao',
                            'apptypeid': clientinfo.OEM ? clientinfo.OEM : PARAM_EMPTY,
                            'ver': clientinfo.Version ? clientinfo.Version : PARAM_EMPTY,
                            'os': clientinfo.Plantform ? clientinfo.Plantform : PARAM_EMPTY,
                            'deviceid': clientinfo.IMEI ? clientinfo.IMEI : PARAM_EMPTY
                        }

                        $.ajax({
                            url: '//stinvi.dftoutiao.com/appstatistics/appact',
                            data: statisData,
                            type: 'GET',
                            dataType: 'jsonp',
                            jsonp: 'jsonpcallback',
                            timeout: 5000,
                            success: function (response) {
                                // console.log(response);
                            }
                        });
                    }
                    report('show1');


                  //点击炫耀一下
                  $('#button').click(function(){
                      var inviteCode = userinfo.Accid.toString();
                      inviteCode = yingshe(inviteCode);

                      $.ttapp.share({
                          shareUrl: 'http://'+ ACT_RANDOM_HOST[parseInt(Math.random()*ACT_RANDOM_HOST.length)] +'/qianghongbao/outside2?f=94014&u='+inviteCode+'&money='+money,   // 正式
                          // shareUrl: 'https://test-kp.dftoutiao.com/qianghongbao/outside2?f=94014&u='+inviteCode+'&money='+money, // test
                          shareTitle: '东方头条狂发百万现金红包，今晚8点准时开抢！',               //分享标题
                          shareDes: '每个新用户进入头条红包池就涨一元，人越多钱越多！',            //分享描述
                          shareImg: 'https://resources.dftoutiao.com/songheng/toutiao/shb/share/shb2_share_logo.png'  //分享图片
                      });
                      report('click3');
                  });

                  //点击跳转广告
                  // $('#button2').click(function(){
                  //     $('#wuyaBg').show();
                  //     var sj = Math.floor(Math.random()*2000 + 1);
                  //     setTimeout(function(){
                  //       window.location.href = "http://cfg.aiclicash.com/hdjump?iclicashid=7314760";
                  //       report('clickAd1');
                  //     },sj);
                  //     setTimeout(function(){
                  //       $('#wuyaBg').hide();
                  //     },2000);
                  // });

              });
      });


     


      layui.use('flow', function(){
        var flow = layui.flow;
        flow.load({
          elem: '#flow1', //指定列表容器
          scrollElem:'#flow1',
          isAuto: true,
          done: function(page, next){ //到达临界点（默认滚动触发），触发下一页
              $.ajax({
                    url: '//mini.eastday.com/songheng/toutiao/appact/songhongbao/takerecord'+ page +'.js',
                    dataType:'jsonp',
                    jsonpCallback: 'callback',
                    success:function(res){
                        var lis = [];
                        layui.each(res, function(index, item){
                          lis.push(
                              '<dl> \
                                <dt><img src="'+item.img+'" alt="" ></dt> \
                                <dd> \
                                  <div class="div1"> \
                                    <span class="span1">'+item.nick+'</span> \
                                    <span class="span2">'+item.m+'元</span> \
                                  </div> \
                                  <div class="div2">'+formatDate(d)+'</div> \
                                </dd> \
                              </dl>'
                          );
                        });
                        next(lis.join(''), page < 50);
                    }
              });
          }
        });
      });



      function is_android(){
            var u = navigator.userAgent;
            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
            return isAndroid;
      }


      function GetQueryString(name){
           var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
           var r = window.location.search.substr(1).match(reg);
           if(r!=null)return  unescape(r[2]); return null;
      }

      function formatDate(now){ 
        var year = new Date().getFullYear();
    		var month= new Date().getMonth()+1; 
    		var date = new Date().getDate();
    		return year+"-"+month+"-"+date;
      } 
      // var d=new Date(nowTime);
      var d=new Date();

      // 邀请码映射
      function yingshe(string){
        var arr = [];
        for (var i = 0; i < string.length; i++) {
            switch(string[i]){
              case '0':
                arr.push('7');
                break;
              case '1':
                arr.push('4');
                break;
              case '2':
                arr.push('8');
                break;
              case '3':
                arr.push('2');
                break;
              case '4':
                arr.push('5');
                break;
              case '5':
                arr.push('1');
                break;
              case '6':
                arr.push('9');
                break;
              case '7':
                arr.push('3');
                break;
              case '8':
                arr.push('0');
                break;
              case '9':
                arr.push('6');
                break;
              default:
                return false;
            }
        }
        return arr.join('');
      }
  })
</script>
</body>
</html>